using System;
using System.IO;
using log4net;
using log4net.Config;

namespace Pcw.PcwTextEditor
{
	
	public enum PcwLogLevel
	{
		DEBUG = 1,
		INFO,
		WARN,
		ERROR,
		FATAL
	}
	
	public static class PcwLog
	{
		
		private static ILog logger = LogManager.GetLogger(typeof(PcwLog));
		
		static PcwLog()
		{
			XmlConfigurator.Configure(new FileInfo("PcwTextEditor.addin"));
		}
		
		public static void WriteLog(PcwLogLevel logLevel, string metodo, string log)
		{
			
			//log = metodo + " - " + log;
			log = log + " - " + metodo;
			
                        switch (logLevel)
                        {
                                case PcwLogLevel.DEBUG:
                        		if (logger.IsDebugEnabled == true)
                        			logger.Debug(log);
                                        break;

                                case PcwLogLevel.INFO:
                        		if (logger.IsInfoEnabled == true)
                        			logger.Info(log);
                                        break;
                                        
                                case PcwLogLevel.WARN:
                        		if (logger.IsWarnEnabled == true)
                        			logger.Warn(log);
                                        break;                          
                                        
                                case PcwLogLevel.ERROR:
                        		if (logger.IsErrorEnabled == true)
                        			logger.Error(log);
                                        break;

                                case PcwLogLevel.FATAL:
                        		if (logger.IsFatalEnabled == true)
                        			logger.Fatal(log);
                                        break;
                                
                                default:
                                        return; 
                                        
                        } //switch (logLevel)			
			

		}		
		
	}
}